package com.maxd.modules.syslog.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;

/**
 * @Auther: Laban:yubo_010@163.com
 * @Date: 2020/11/18 09:27
 * @Description:
 */
@Data
@Entity
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Table(name = "sqx_request_logs")
@ApiModel(value = "sqx_request_logs对象", description = "API请求日志管理")
public class RequestLogs implements Serializable {


    @Id()
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    /**主键ID*/
    private Long id;

    @Column(name = "create_time")
    /**创建时间*/
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date createTime;

    @Column(name = "request_time")
    /**创建时间*/
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date requestTime;

    @Column(name = "request_method_name")
    /**请求方法名*/
    private String requestMethodName;


    @Column(name = "request_source")
    /**请求来源*/
    private String requestSource;


    @Column(name = "request_url")
    /**请求url*/
    private String requestUrl;


    @Lob
    @Column(name = "request_value",columnDefinition="text")
    /**请求参数*/
    private String requestValue;

    /**
     * save RequestLogs
     * @param createTime
     * @param requestTime
     * @param requestMethodName
     * @param requestSource
     * @param requestUrl
     * @param requestValue
     * @return
     */
    public RequestLogs saveRequestLogs(java.util.Date createTime,java.util.Date requestTime,
           String requestMethodName,String requestSource,String requestUrl,String requestValue){
        RequestLogs requestLogs = new RequestLogs();
        requestLogs.setCreateTime(createTime);
        requestLogs.setRequestTime(requestTime);
        requestLogs.setRequestMethodName(requestMethodName);
        requestLogs.setRequestSource(requestSource);
        requestLogs.setRequestUrl(requestUrl);
        requestLogs.setRequestValue(requestValue);
        return requestLogs;
    }

}
